package old.galaxyGeneration;

import objects.GameSettings;
import objects.Universe;
import objects.physicalEntities.Star;
import inputOutput.PlayerSettings;

public class UniformGalaxy extends Galaxy 
{
	public UniformGalaxy(){}
	
	public UniformGalaxy(GameSettings gameSettings, Universe universe) 
	{		
		super(gameSettings, universe);		
		this.galaxyGenerator();
	}
	
	protected void galaxyGenerator()
	{		
		double starBorderZone1 = 3;
		double starBorderZone2 = uniLength-4;
		//Reset array (just in case)
		for (int i = 0; i < uniLength; i++)
		{
			for (int j = 0; j < uniLength; j++)
			{
				starGrid[i][j] = 0;
			}
		}
		
		
		for (starsPlaced = 0; starsPlaced < numStars; starsPlaced++)
		{
			tempX = uniLength/4+randUni.nextDouble()*workingLength;
			tempY = uniLength/4+randUni.nextDouble()*workingLength;

			x = (int)tempX;
			y = (int)tempY;

			if ((x > starBorderZone1) & (y > starBorderZone1) & (x < starBorderZone2) & (y < starBorderZone2))
			{
				//check starGrid values at location
				if (starGrid[x][y] == 0)
				{
					universe.AddStar(new StarModel(x,y));
					updateGrid(x,y);					
				}

				else if ((starGrid[x][y] == 1) & (randUni.nextDouble() < ringTwo))
				{
					universe.AddStar(new StarModel(x,y));
					updateGrid(x,y);						
				}

				else if ((starGrid[x][y] == 2) & (randUni.nextDouble() < ringOne))
				{
					universe.AddStar(new StarModel(x,y));
					updateGrid(x,y);
				}
				else
				{starsPlaced -= 1;}
				//if outside the grid, subt 1 from i, loop again
			}
			else 
			{starsPlaced -= 1;}
			//System.out.println(stars.size());				
		}
		universe.PrintStars();
		
	}
}
